﻿
namespace SomethingSpacialClassLib.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Data;
    using System.Linq;
    using System.ServiceModel.DomainServices.Server;
    using System.ServiceModel.DomainServices.EntityFramework;
    using System.ServiceModel.DomainServices.Hosting;


    // Implements application logic using the SUGWTKEntities1 context.
    // TODO: Add your application logic to these methods or in additional methods.
    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
    // Also consider adding roles to restrict access as appropriate.
    // [RequiresAuthentication]
    public partial class SomethingSpacialService : LinqToEntitiesDomainService<SUGWTKEntities1>
    {
        
        // TODO: Consider
        // 1. Adding parameters to this method and constraining returned results, and/or
        // 2. Adding query methods taking different parameters.
        public IQueryable<Job> GetJobs()
        {
            return this.ObjectContext.Jobs;
        }

        public void InsertJob(Job job)
        {
                if ((job.EntityState != EntityState.Detached))
                {
                    this.ObjectContext.ObjectStateManager.ChangeObjectState(job, EntityState.Added);
                }
                else
                {
                    this.ObjectContext.Jobs.AddObject(job);
                }
         
        }

        public void UpdateJob(Job currentJob)
        {
                this.ObjectContext.Jobs.AttachAsModified(currentJob, this.ChangeSet.GetOriginal(currentJob));
        
        }

        public void DeleteJob(Job job)
        {
            if ((job.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Attach(job);
            }
            this.ObjectContext.Jobs.DeleteObject(job);
        }




 
    }
}


